import TimeUtils from "src/_T/Utils/TimeUtils";
import AchievementTask from "./AchievementTask";
import EverdyTask from "./EverdyTask";

export default class TaskManager {
    private constructor() { };
    private static _Instance: TaskManager;
    public static get Instance(): TaskManager {
        if (this._Instance == null) { this._Instance = new TaskManager(); }
        return this._Instance;
    }

    /**成就任务列表 */
    m_AchievementTaskList: Array<AchievementTask>;

    /**每日任务列表 */
    m_EverdyTaskList: Array<EverdyTask>;

    public InitTask() {
        this.m_AchievementTaskList = new Array<AchievementTask>();
        this.m_EverdyTaskList = new Array<EverdyTask>();
        this.ReadTaskMemory();
        this.ReadEverdyTaskMemory();
    }

    //#region  任务列表参数获取方法

    /*****-------------------------每日任务 */
    /**返回每日任务长度 */
    public GetEverdyTasklength(): number {
        return this.m_EverdyTaskList.length;
    }
    /**获取每日任务列表 */
    public GetEverdyTaskList(): Array<EverdyTask> {
        return this.m_EverdyTaskList;
    }
    /**根据下标获取每日任务数据 */
    public GetEverdyTaskDataByIndex(Index: number): EverdyTask {
        if (!this.m_EverdyTaskList) return null;
        if (this.m_EverdyTaskList.length == 0) return null;
        if (Index < 0 || Index >= this.m_EverdyTaskList.length) return null;
        return this.m_EverdyTaskList[Index];
    }

    /*****-------------------------成就任务 */
    /**返回成就任务长度 */
    public GetAchievementTasklength(): number {
        return this.m_AchievementTaskList.length;
    }
    /**获取成就任务列表 */
    public GetAchievementTaskList(): Array<AchievementTask> {
        return this.m_AchievementTaskList;
    }
    /**根据下标获取成就任务数据 */
    public GetAchievementTaskDataByIndex(Index: number): AchievementTask {
        if (!this.m_AchievementTaskList) return null;
        if (this.m_AchievementTaskList.length == 0) return null;
        if (Index < 0 || Index >= this.m_AchievementTaskList.length) return null;
        return this.m_AchievementTaskList[Index];
    }
    //#endregion

    /**读取任务内存 */
    private ReadTaskMemory() {
        /**读取成就任务 */
        // let Len = AchievementMediator.instance.data.dataList.length;
        // for (let i = 0; i < Len; i++) {
        //     let Temp = AchievementMediator.instance.data.dataList[i];
        //     //let TempTask: AchievementTask = new AchievementTask(Temp);
        //     this.m_AchievementTaskList.push(TempTask);
        // }
    }
    /**读取每日任务内存 */
    private ReadEverdyTaskMemory() {
        // let EverydatLen = EveryDayMediator.instance.data.dataList.length;
        // for (let i = 0; i < EverydatLen; i++) {
        //     let Temp = EveryDayMediator.instance.data.dataList[i];
        //     let TempTask: EverdyTask = new EverdyTask(Temp);
        //     this.m_EverdyTaskList.push(TempTask);
        // }
    }
    /**检测是否刷新每日任务 */
    CheckEverdyTaskIsRefresh() {
        // let curTime: number = TimeUtils.GetCurrentDayCount(new Date().getTime());
        // let curIndex: number = curTime - MainDataMediator.instance.data.EverydayTime;
        // if (MainDataMediator.instance.data.EverydayTime == 0 || curIndex > 0) {
        //     //刷新
        //     this.RefreshEverdyTask();
        // }
    }

    /**刷新每日任务 */
    RefreshEverdyTask() {

    }

    /**保存成就任务 */
    SaveAchievementTask() {

    }
    /**保存每日任务 */
    SaveEverdyTask() {

    }

}